// 在原链上做反转
function reverseLink(head1) {
    if (!head1) return null;
    let prev = null;
    let cur = head1;
    while (cur) {
        let next = cur.next;
        cur.next = prev;
        prev = cur;
        cur = next;
    }
    return prev;
}

// 新建新的链表
function reverseLink1(head) {
    if (!head) return null;
    let newHead = null;
    while (head) {
        let next = head;
        // 新建一个新的链表节点
        let newNext = {val: head.val};
        newNext.next = newHead;
        newHead = newNext;
        head = head.next;
    }
    return newHead;
}